package com.cdd.role.controller;

import com.cdd.role.service.RoleService;
import com.cdd.role.vo.Pages;
import com.common.entity.Role;
import com.common.untils.CommonResult;
import com.common.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO
 *
 * @author lenovo
 * @version 1.0
 * @since 2022-09-01  21:12:11
 */
@RestController
@RequestMapping("/role/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    //查询全部
    @PostMapping("/queryAll/{currentPage}/{pageSize}")
    public CommonResult queryAll(@PathVariable Integer currentPage,@PathVariable Integer pageSize,@RequestBody Role role){
        return  roleService.queryAll(currentPage,pageSize,role);
    }
    //添加角色
    @PostMapping("/addRole")
    public CommonResult add(@RequestBody Role role){
        return roleService.insetRole(role);
    }
    //修改角色
    @PostMapping("/updateRole")
    public CommonResult update(@RequestBody Role role){
        return roleService.update(role);
    }
    //修改状态
    @PostMapping("/updateState/{roleId}/{state}")
    public CommonResult state(@PathVariable String roleId,@PathVariable Integer state){
        return roleService.updateState(roleId,state);
    }
    //删除角色
    @PostMapping("deleteRole/{roleId}")
    public CommonResult deleteRole(@PathVariable String roleId){
        return roleService.deleted(roleId);
    }
    //根据角色id查询当前角色具有的权限和所有权限
    @PostMapping("selectPermission/{roleId}")
    public CommonResult selectPermission(@PathVariable String roleId){
        return roleService.selectPermission(roleId);
    }

}
